//商品相关接口
import request from '@u/request';

const COMMODITY_TYPE_HOST = '/api/admin/product/type'//商品分类相关接口
const COMMODITY_PROPERTIES_HOST = '/api/admin/specs/key' //商品规格
const COMMODITY_PROPERTIES_VALUE_HOST = '/api/admin/specs/value' //规格详情
const PRODUCT_API_HOST = '/api/admin/product' //商品相关接口

const commodity = {
    //分类列表
    categoryList : params => {
        return request({
            url : COMMODITY_TYPE_HOST,
            params,
            method : 'get'
        })
    },
    //分类删除
    categoryDelete : params => {
        return request({
            url : COMMODITY_TYPE_HOST,
            params,
            method : 'delete'
        })
    },
    //分类添加
    categoryCreate : data => {
        return request({
            url : COMMODITY_TYPE_HOST,
            data,
            method : 'post'
        })
    },
    //分类编辑
    categoryUpdate : data => {
        return request({
            url : COMMODITY_TYPE_HOST,
            data,
            method : 'put'
        })
    },

    //规格列表
    specsList : params => {
        return request({
            url : COMMODITY_PROPERTIES_HOST,
            params,
            method : 'get'
        })
    },
    //删除规格
    specsDelete : params => {
        return request({
            url : COMMODITY_PROPERTIES_HOST,
            params,
            method : 'delete'
        })
    },
    //规格创建
    specsCreate : data => {
        return request({
            url : COMMODITY_PROPERTIES_HOST,
            data,
            method : 'post'
        })
    },
    //规格更新
    specsUpdate : data => {
        return request({
            url : COMMODITY_PROPERTIES_HOST,
            data,
            method : 'put'
        })
    },

    //添加指列表
    specsValueList : params => {
        return request({
            url : COMMODITY_PROPERTIES_VALUE_HOST,
            params,
            method : 'get'
        })
    },
    //规格值删除
    specsValueDelete : params => {
        return request({
            url : COMMODITY_PROPERTIES_VALUE_HOST,
            params,
            method : 'delete'
        })
    },
    //添加规格值
    specsValueCreate : data => {
        return request({
            url : COMMODITY_PROPERTIES_VALUE_HOST,
            data,
            method : 'post'
        })
    },
    //更新规格值
    specsValueUpdate : data => {
        return request({
            url : COMMODITY_PROPERTIES_VALUE_HOST,
            data,
            method : 'put'
        })
    },
    

    //商品列表
    productList : params => {
        return request({
            url : PRODUCT_API_HOST,
            params,
            method : 'get'
        })
    },
    //商品删除
    productDelete : params => {
        return request({
            url : PRODUCT_API_HOST,
            params,
            method : 'delete'
        })
    },
    //创建商品
    productCreate : data => {
        return request({
            url : PRODUCT_API_HOST,
            data,
            method : 'post'
        })
    },
    //商品更新
    productUpdate : data => {
        return request({
            url : PRODUCT_API_HOST,
            data,
            method : 'put'
        })
    },
    //商品信息
    productInfo : params => {
        return request({
            url : `${PRODUCT_API_HOST}/info`,
            params,
            method : 'get'
        })
    },
}


export default commodity